<template>
  <div>
    <!--面包屑导航区域-->
    <el-breadcrumb separator-class="el-icon-arrow-right">
      <el-breadcrumb-item :to="{ path: '/home' }">首页</el-breadcrumb-item>
      <el-breadcrumb-item>订单管理</el-breadcrumb-item>
      <el-breadcrumb-item>订单列表</el-breadcrumb-item>
    </el-breadcrumb>
    <!-- 卡片视图区域 -->
    <el-card>
      <el-row>
        <el-col :span="8">
          <div style="margin-top: 15px;">
            <el-input placeholder="请输入内容" v-model="queryInfo.query">
              <el-button slot="append" icon="el-icon-search"></el-button>
            </el-input>
          </div>
        </el-col>
      </el-row>
      <el-table
    :data="orderList"
    style="width: 100%"
    stripe
    border>
    <el-table-column
      label="#"
      type="index">
    </el-table-column>
    <el-table-column
      prop="order_number"
      label="订单编号">
    </el-table-column>
    <el-table-column
      prop="order_price"
      label="订单价格"
      width="180">
    </el-table-column>
    <el-table-column
      prop="pay_status"
      label="是否付款"
      width="180">
      <template slot-scope="scope">
        <el-tag v-if="scope.row.pay_status!=='0'">已付款</el-tag>
        <el-tag v-if="scope.row.pay_status==='0'" type="warning">未付款</el-tag>
      </template>
    </el-table-column>
    <el-table-column
      prop="is_send"
      label="是否发货"
      width="180">
    </el-table-column>
    <el-table-column
      prop="create_time"
      label="下单时间"
      width="180">
      <template slot-scope="scope">
          {{scope.row.create_time | dateformat}}
        </template>
    </el-table-column>
    <el-table-column
      label="操作"
      width="120">
      <template>
        <el-button type="primary" icon="el-icon-edit" size="mini"></el-button>
        <el-button type="success" icon="el-icon-location" size="mini"
        @click="showProgress"></el-button>
      </template>
    </el-table-column>
      </el-table>
      <!-- 分页区域 -->
      <el-pagination
        @size-change="handleSizeChange"
        @current-change="handleCurrentChange"
        :current-page="queryInfo.pagenum"
        :page-sizes="[10, 20, 50, 100, 200, 300, 400]"
        :page-size="queryInfo.pagesize"
        layout="total, sizes, prev, pager, next, jumper"
        :total="total" background>
      </el-pagination>
    </el-card>
    <!-- <el-dialog
      title="提示"
      :visible.sync="dialogVisible"
      width="30%"
      :before-close="handleClose">
      <span>这是一段信息</span>
      <span slot="footer" class="dialog-footer">
        <el-button @click="dialogVisible = false">取 消</el-button>
        <el-button type="primary" @click="dialogVisible = false">确 定</el-button>
      </span>
    </el-dialog> -->
  </div>
</template>

<script>
export default {
  data() {
    return {
      queryInfo: {
        // 查询条件
        query: '',
        // 查询页码
        pagenum: 1,
        pagesize: 10,

      },
      orderList: [],
      total: 0,
    }
  },
  created() {
    this.getOrderList() 
  },
  methods: {
    async getOrderList() {
      const {data: res} = await this.$http.get('orders', {
        params: this.queryInfo
      })
      if(res.meta.status !== 200) {
        return this.$message.error('获取订单列表数据失败！')
      }
      this.total = res.data.total
      this.orderList = res.data.goods
      // console.log(this.orderList);
    },
    // 每页显示的件数改变
    handleSizeChange(newSize) {
      this.queryInfo.pagesize = newSize
      this.getOrderList()
    },
    // 页数改变
    handleCurrentChange(newPage) {
      this.queryInfo.pagenum = newPage
      this.getOrderList()
    },
    // 展示物流信息
    async showProgress() {
      const {data: res} = await this.$http.get('/kuaidi/1106975712662')
      console.log(res);
    },
  }
}
</script>

<style lang="less" scoped>

</style>

